package com.naizhuai.ui.mianbusiness.action.presenter;

import com.naizhuai.AppContext;
import com.naizhuai.network.Config;
import com.naizhuai.network.RetrofitServerFactory;
import com.naizhuai.network.apistore.ActionManageRequest;
import com.naizhuai.network.apistore.DownloadImageRequest;
import com.naizhuai.ui.entity.mainbusiness.ActionEditContractActivityBean;
import com.naizhuai.ui.entity.mainbusiness.ActionMainBean;
import com.naizhuai.util.RxUtils;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

import okhttp3.ResponseBody;
import retrofit2.Call;
import rx.Observable;
import rx.functions.Func1;
import rx.schedulers.Schedulers;

/**
 * 处理公共搜索的类
 * Created by code_han on 2018/1/25.
 */

public class ActionManageApiStoreIml implements ActionManageApiStore {

    private static ActionManageApiStore INSTANCE = null;

    public static ActionManageApiStore getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new ActionManageApiStoreIml();
        }
        return INSTANCE;
    }

    @Override
    public Observable<ActionEditContractActivityBean> getComparePagerMsg(String questionId) {
        return createBaseClass().getComparePagerMsg(questionId).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<ActionEditContractActivityBean> getProcessDetails(String questionId) {
        return createBaseClass().getProcessDetails(questionId).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<ActionEditContractActivityBean> getExamineDataDetails(String questionId) {
        return createBaseClass().getExamineDataDetails(questionId).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<String> submitActionDetails(Map<String, String> submitActionMessage) {
        return createBaseClass().submitActionDetails(submitActionMessage).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<String> submitActionProcess(Map<String, String> submitProcessMessage) {
        return createBaseClass().submitActionProcess(submitProcessMessage).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<String> submitExamineDetails(Map<String, String> submitExamineDetails) {
        return createBaseClass().submitExamineDetails(submitExamineDetails).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<ActionMainBean> getActionMainPager(String companyId) {
        return createBaseClass().getActionMainPager(companyId).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<ActionEditContractActivityBean> getActionBrightPointMsg(String actionId) {
        return createBaseClass().getActionBrightPointMsg(actionId).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<ActionEditContractActivityBean> getActionBeforeDetals(String actionId) {
        return createBaseClass().getActionBeforeDetails(actionId).compose(RxUtils.applySchedulers());
    }


    private ActionManageRequest createBaseClass() {
        return RetrofitServerFactory.create(AppContext.getInstance(), ActionManageRequest.class, Config.TEST_ACTION_BASE_URL);
    }

}
